﻿using System.Diagnostics;

namespace DimensionsHelper.LanguageService.Syntax;

public class MetadataElementType : MetadataSingleArgumentSuffix<Identifier>
{
    internal MetadataElementType(SyntaxToken declareKeywordToken, SyntaxNode? parent) :
        base(SyntaxKinds.MetadataElementType,
            declareKeywordToken,
            NodeConverter.ToIdentifier(
                declareKeywordToken), // elementtype (...) -> NameNode 和 DeclareKeywordToken 实际上是一样的
            parent)
    {
    }


    public override void AcceptVisitor<T>(SyntaxNodeVisitor<T> visitor)
    {
        Accept(visitor, DeclareKeywordToken, Argument);
    }
}


public static partial class NodeFactory
{
    public static MetadataElementType CreateMetadataElementType(SyntaxNode? parent, SyntaxToken declareKeywordToken,
        Identifier? value)
    {
        Debug.Assert(declareKeywordToken.IsNode(SyntaxKinds.ElementTypeKeywordToken));
        MetadataElementType elementType = new(declareKeywordToken, parent);
        return UpdateMetadataSingleArgumentSuffix(elementType, value);
    }
}